﻿using com.cruxomatic.DTOs;

namespace com.cruxomatic.BusinessObjects
{
    public class ClassConverter
    {
        public static UserInformation CopyUserToUserInformation(User user)
        {
            UserInformation userInformation = new UserInformation();
            userInformation.UserID = user.UserID;
            userInformation.UserName = user.UserName;
            userInformation.FirstName = user.FirstName;
            userInformation.MiddleName = user.MiddleName;
            userInformation.LastName = user.LastName;
            userInformation.UserComments = user.UserComments;
            userInformation.CompanyName = user.Company.CompanyName;
            userInformation.CompanyID = user.Company.CompanyID;
            userInformation.SecurityAnswer = user.SecurityAnswer;
            return userInformation;
        }

        public static RoleInformation CopyRoleToRoleInformation(Role role)
        {
            RoleInformation roleInformation = new RoleInformation
            {
                RoleID = role.RoleID,
                RoleName = role.RoleName,
                RoleDescription = role.RoleDescription,
                IsSystemGenerated = role.IsSystemGenerated,
                Comments = role.Comments
            };
            return roleInformation;
        }
        public static Role CopyRoleInformationToRole(RoleInformation role, Role dbRole)
        {
            dbRole.RoleID = role.RoleID;
            dbRole.RoleName = role.RoleName;
            dbRole.RoleDescription = role.RoleDescription;
            dbRole.Comments = role.Comments;
            dbRole.IsSystemGenerated = role.IsSystemGenerated;
            return dbRole;
        }

        public static CompanyInformation CopyCompanyToCompanyInformation(Company company)
        {
            CompanyInformation companyInformation = new CompanyInformation
            {
                CompanyID = company.CompanyID,
                CompanyTypeID = company.CompanyType.CompanyTypeID,
                CompanyName = company.CompanyName,
                CompanyType = company.CompanyType.CompanyTypeName,
                CompanyBillingAddress = company.CompanyBillingAddress,
                CompanyMailingAddress = company.CompanyMailingAddress,
                ParentCompanyID = company.ParentCompanyID,
                CompanyComments = company.CompanyComments
            };
            return companyInformation;
        }

        public static Company CopyCompanyInformationToCompany(CompanyInformation company, Company dbCompany)
        {
            dbCompany.CompanyID = company.CompanyID;
            dbCompany.CompanyName = company.CompanyName;
            dbCompany.CompanyTypeID = company.CompanyTypeID;
            dbCompany.CompanyBillingAddress = company.CompanyBillingAddress;
            dbCompany.CompanyMailingAddress = company.CompanyMailingAddress;
            dbCompany.CompanyComments = company.CompanyComments;
            dbCompany.ParentCompanyID = company.ParentCompanyID;
            return dbCompany;
        }
        
        public static LocationInformation CopyLocationToLocationInfomration(Location location)
        {
            LocationInformation locationInformation = new LocationInformation
              {
                  LocationID = location.LocationID,
                  LocationName = location.LocationName,
                  LocationAddress = location.LocationAddress,
                  LocationComments = location.LocationComments,
                  CompanyID = location.CompanyID,
                  CompanyName = location.Company.CompanyName
              };
            return locationInformation;
        }

        public static Location CopyLocationInformationToLocation(LocationInformation locationInformation, Location location)
        {
            location.LocationID = locationInformation.LocationID;
            location.LocationName = locationInformation.LocationName;
            location.LocationAddress = locationInformation.LocationAddress;
            location.LocationComments = locationInformation.LocationComments;
            location.CompanyID = locationInformation.CompanyID;
            return location;
        }


        public static SubLocationInformation CopySubLocationToSubLocationInfomration(SubLocation SubLocation)
        {
            SubLocationInformation subLocationInformation = new SubLocationInformation
            {
                SubLocationID = SubLocation.SubLocationID,
                SubLocationName = SubLocation.SubLocationName,
                SubLocationAddress = SubLocation.SubLocationAddress,
                SubLocationComments =
                SubLocation.SubLocationComments,
                ParentLocationID = SubLocation.LocationID
            };
            return subLocationInformation;
        }

        public static SubLocation CopySubLocationInformationToSubLocation(SubLocationInformation SubLocation, SubLocation dbSubLocation)
        {
            dbSubLocation.SubLocationID = SubLocation.SubLocationID;
            dbSubLocation.SubLocationName = SubLocation.SubLocationName;
            dbSubLocation.SubLocationAddress = SubLocation.SubLocationAddress;
            dbSubLocation.SubLocationComments = SubLocation.SubLocationComments;
            dbSubLocation.LocationID = SubLocation.ParentLocationID;
            return dbSubLocation;
        }

        public static DepartmentInformation CopyDepartmentToDepartmentInformation(Department department)
        {
            DepartmentInformation departmentInformation = new DepartmentInformation
              {
                  DepartmentID = department.DepartmentID,
                  DepartmentName = department.DepartmentName,
                  DepartmentDescription = department.DepartmentDescription,
                  DepartmentComments = department.DepartmentComments,
                  CompanyID = department.CompanyID,
                  CompanyName = department.Company.CompanyName
              };
            return departmentInformation;
        }

        public static Department CopyDeparmentInformationToDepartment(DepartmentInformation department, Department dbDepartment)
        {
            dbDepartment.DepartmentID = department.DepartmentID;
            dbDepartment.DepartmentName = department.DepartmentName;
            dbDepartment.DepartmentDescription = department.DepartmentDescription;
            dbDepartment.DepartmentComments = department.DepartmentComments;
            dbDepartment.CompanyID = department.CompanyID;
            return dbDepartment;
        }



        public static User CopyUserInformationToUser(UserInformation user, User dbUser)
        {
            dbUser.UserID = user.UserID;
            dbUser.UserName = user.UserName;
            dbUser.FirstName = user.FirstName;
            dbUser.MiddleName = user.MiddleName;
            dbUser.LastName = user.LastName;
            dbUser.UserComments = user.UserComments;
            dbUser.CompanyID = user.CompanyID;
            return dbUser;
        }

        public static CompanyTypeInformation CopyCompanyTypeToCompanyTypeInformation(CompanyType companyType)
        {
            CompanyTypeInformation companyTypeInformation = new CompanyTypeInformation
            {
                CompanyTypeID = companyType.CompanyTypeID,
                CompanyTypeName = companyType.CompanyTypeName
            };
            companyTypeInformation.CompanyTypeComments = companyTypeInformation.CompanyTypeComments;
            return companyTypeInformation;
        }


        public static PrivilageInformation CopyPrivilageToPrivilageInformation(Privilage rolePrivilage)
        {
            PrivilageInformation privilageInformation = new PrivilageInformation
            {
                PrivilageID = rolePrivilage.PrivilageID,
                PrivilageName = rolePrivilage.PrivilageName,
                PrivilageDescription=rolePrivilage.PrivilageDescription
            };
           
            return privilageInformation;
        }

        public static Privilage CopyPrivilageInformationToPrivilage(PrivilageInformation privilage, Privilage dbPrivilage)
        {
            dbPrivilage.PrivilageID = privilage.PrivilageID;
            dbPrivilage.PrivilageName = privilage.PrivilageName;
            dbPrivilage.PrivilageDescription = privilage.PrivilageDescription;
            return dbPrivilage;
        }

        public static CompanyType CopyCompanyTypeInformationToCompanyType(CompanyTypeInformation companyTypeInformation)
        {
            CompanyType companyType = new CompanyType
            {
                CompanyTypeID = companyTypeInformation.CompanyTypeID,
                CompanyTypeName = companyTypeInformation.CompanyTypeName
            };
            companyType.Comments = companyTypeInformation.CompanyTypeComments;
            return companyType;
        }

        public static SecurityQuestionInformation CopySecurityQuestionToSecurityQuestionInformation(SecurityQuestion question)
        {
            SecurityQuestionInformation questionInfo = new SecurityQuestionInformation()
            {
                ID = question.ID,
                Question = question.Question
            };
            return questionInfo;
        }
        public static SecurityQuestion CopySecurityQuestionInformationToSecurityQuestion(SecurityQuestionInformation ques, SecurityQuestion dbQues)
        {
            dbQues.ID = ques.ID;
            dbQues.Question = ques.Question;
            return dbQues;
        }

        public static MasterLocationInformation CopyMasterLocationToMasterLocationInformation(MasterLocation paramMasterLocation)
        {
            return (new MasterLocationInformation
            {

                MasterLocationID = paramMasterLocation.MasterLocationID,
                LocationCode = paramMasterLocation.LocationCode,
                LocationName = paramMasterLocation.LocationName,
                LocationDescription = paramMasterLocation.LocationDescription
            });
        }

        public static MasterLocation CopyMasterLocationInformationToMasterLocation(MasterLocationInformation prmMasterLocationInformation, MasterLocation dbMasterLocation)
        {

            dbMasterLocation.MasterLocationID = prmMasterLocationInformation.MasterLocationID;
            dbMasterLocation.LocationCode = prmMasterLocationInformation.LocationCode;
            dbMasterLocation.LocationName = prmMasterLocationInformation.LocationName;
            dbMasterLocation.LocationDescription = prmMasterLocationInformation.LocationDescription;
            return dbMasterLocation;
        }

        public static CompanyMasterLocation CopyCompanyMasterLocationInfoToMasterLocation(
            CompanyMasterLocationInformation info, CompanyMasterLocation dbobject)
        {
            dbobject.CompanyID = info.CompanyID;
            dbobject.MasterLocationID = info.MasterLocationID;
            return dbobject;
        }
    }
}
